/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-01-10 16:02:08
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-08-02 18:16:44
 * @FilePath: \cxl-h5\src\apis\login\index.ts
 */
import { request as axios } from '@/axios/index'

/**
 * 登录接口
 * @param phone
 * @param password
 * @returns
 */
export const login = (data: FormData) => {
    return axios({
        method: 'post',
        url: '/api/system/portal/login/submit',
        data
    })
}

/**
 * 验证验证码是否正确 （按需使用该接口）
 * @param phone
 * @param code
 * @returns
 */
export const checkverificationCode = (phone: string, code: string) => {
    return axios({
        method: 'post',
        url: `/api/system/portal/login/checkSmsResetPasswordCode/${phone}/${code}`
    })
}

/**
 * 退出登录
 * @returns
 */
export const logout = () => {
    return axios({
        method: 'post',
        url: '/api/system/portal/login/out'
    })
}

/**
 * 刷新token
 * @returns
 */
export const refreshToken = () => {
    return axios({
        method: 'post',
        url: '/api/system/portal/login/refreshToken'
    })
}

/**
 * 重置密码
 * @param code
 * @param password
 * @param phone
 * @returns
 */
export const resetPassword = (code: string, password: string, phone: string) => {
    return axios({
        method: 'post',
        url: '/api/system/portal/login/resetPassword',
        data: {
            code,
            password,
            phone
        }
    })
}

/**
 * 获取重置密码的验证码
 * @param phone
 * @returns
 */
export const getResetPasswordCode = (phone: string) => {
    return axios({
        method: 'post',
        url: `/api/system/portal/login/sendResetPasswordCode/${phone}`
    })
}

export const generateToken = () => {
    return axios({
        method: 'post',
        url: '/api/system/token/generateToken'
    })
}
